package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.repository.entity.DictsortDetail;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class DictsortDetailVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "类型名称")
    private String name;

    @ApiModelProperty(value = "字典类型编码")
    private String codeType;

    @ApiModelProperty(value = "键值")
    private Integer value;

    @ApiModelProperty(value = "备用字段")
    private String standby;

    @ApiModelProperty(value = "是否有效：0有效，1无效")
    private Integer status;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static DictsortDetail convert(DictsortDetailVO vo) {
        DictsortDetail entity = new DictsortDetail();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<DictsortDetail> convertList(List<DictsortDetailVO> list) {
        List<DictsortDetail> resultList = new ArrayList<>();
        for (DictsortDetailVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
